#include "./private/QRONode_P.h"
#include "QRemoteFunction.h"

QRONode::QRONode():_P(new Private(this))
{
    connect(this,&QRONode::objectLinked,[](QObject* obj){
        auto item = dynamic_cast<QRemoteFunction*>(obj);
        if(item)
        {
            item->onOnline();
        }
    });

    connect(this,&QRONode::objectDislinked,[](QObject* obj){
        auto item = dynamic_cast<QRemoteFunction*>(obj);
        if(item)
        {
            item->onOffline();
        }
    });
}

QRONode::~QRONode()
{
    delete _P;
}

QObject* QRONode::getOccupiedObject()
{
    return _P->getOccupiedObject();
}

void QRONode::connectToHost(QString host,QVariant cookie)
{
    _P->onConnectToHost(host,cookie);
}

void QRONode::unregisterObject(QObject *obj)
{
    _P->onUnregisterObject(obj);
}

void QRONode::activeMethod(QObject *obj, int method, QVariantList param,QRemoteObject2::InvokeCallBack callBack)
{
    _P->onActiveMethod(obj,method,param,callBack);
}

void QRONode::pushProperty(QObject *target, int prop, QVariant value)
{
    _P->onPushProperty(target,prop,value);
}

void QRONode::pushParent(QObject *target, QObject *parent)
{
    _P->onPushParent(target,parent);
}

void QRONode::occupyObject(QObject *target)
{
    _P->onOccupyObject(target);
}

void QRONode::releaseObject(QObject *target)
{
    _P->onReleaseObject(target);
}
